package com.Service;

import com.Dao.GetReplyDao;
import com.Dao.InsertInfoDao;
import com.Dao.UpdateBookInfoDao;
import com.pojo.FindReply;
import com.pojo.Reply;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
@Slf4j
public class CommentService {
    @Autowired
    private InsertInfoDao insertInfoDao;
    @Autowired
    private UpdateBookInfoDao updateBookInfoDao;
    @Autowired
    private GetReplyDao getReplyDao;
    public void insertComment(String username,String bookId,String comment,String timestamp) throws SQLException {
        int id=Integer.parseInt(bookId);
        insertInfoDao.insertComment(username,id,comment,timestamp);
    }
    public void updateRecommend(String bookId,String recommendQuan,String username) throws SQLException {
        int id=Integer.parseInt(bookId);
        int quantity=Integer.parseInt(recommendQuan);
       updateBookInfoDao.updateRecommendQuantity(id,quantity,username);
    }
    public void insertReply(Reply reply) throws SQLException {
         insertInfoDao.insertReply(reply);
    }
    public List<FindReply>getReplyById(String commendId) throws SQLException {
        int id=Integer.parseInt(commendId);
        return getReplyDao.getReplyById(id);
    }
}
